package com.elitel.frame.base.controller.common;

//import sun.misc.BASE64Encoder;
import java.util.Base64;

import java.io.File;
import java.io.FileInputStream;

public class IndexUtil {

  public static String getFuncPage(String module) {

    String page = "";
    String func = "";

    switch (module) {
      case "systemMain": // 基础框架后台管理
        func = "systemManage";
        page = "/systemLayout";
        break;
      case "systemDataSource":
        func = "systemManage";
        page = "/systemDataSource";
        break;
      case "systemDataConfig":
        func = "systemManage";
        page = "/systemDataConfig";
        break;
      case "systemDataView":
        func = "systemManage";
        page = "/systemDataView";
        break;
      case "FieldList":
        func = "systemManage";
        page = "/DataFieldList";
        break;
      case "singleTableService": // 服务管理
        func = "serviceConfigration";
        page = "/singleTableService";
        break;
      case "queryFieldList":
        func = "serviceConfigration";
        page = "/queryFieldList";
        break;
        // 报表服务页面
      case "reportServer":
        func = "serviceConfigration";
        page = "/reportserver";
        break;
      case "singleReport":
        func = "serviceConfigration";
        page = "/singleReportServer";
        break;
      case "dataServices":
        func = "serviceConfigration";
        page = "/dataServices";
        break;
      case "masterDetail":
        func = "serviceConfigration";
        page = "/masterDetailTableService";
        break;
      case "code":
        func = "serviceConfigration";
        page = "/code";
        break;
      case "server":
        func = "serviceConfigration";
        page = "/server";
        break;
      case "census":
        func = "serviceConfigration";
        page = "/census";
        break;
      case "jarServiceConfig":
        func = "serviceConfigration";
        page = "/jarServiceConfig";
        break;
      case "censuses":
        func = "serviceConfigration";
        page = "/censuses";
        break;
      case "uploadFile":
        func = "serviceConfigration";
        page = "/uploadFile";
        break;
      case "group":
        func = "grouping";
        page = "/groupList";
        break;
      case "pageConfig":
        func = "grouping";
        page = "/pageConfig";
        break;
      case "treeConfigure":
        func = "serviceConfigration";
        page = "/treeConfigure";
        break;
      case "redisMonitor":
        func = "serviceConfigration";
        page = "/redisMonitor";
        break;
      case "reportTemplate":
        func = "systemManage";
        page = "/jasperReportTemplate";
        break;
      case "logger":
        func = "systemManage";
        page = "/loggerInfo";
        break;
      case "sqlInfo":
        func = "systemManage";
        page = "/sqlInfo";
        break;
      case "performanceMonitor":
        func = "systemManage";
        page = "/performanceMonitor";
        break;
      case "authorization":
        func = "systemManage";
        page = "/authorizationManager";
        break;
      case "showFieldList":
        func = "serviceConfigration";
        page = "/showFieldList";
        break;
        // 工程管理页面
      case "projectManager":
        func = "project";
        page = "/projectManager";
        break;
        // 服务管理页面
      case "prjService":
        func = "serviceConfigration";
        page = "/prjService";
        break;
      case "serviceMenu":
        func = "serviceMenu";
        page = "/serviceMenu";
        break;
      case "queryConditionConfig":
        func = "serviceConfigration";
        page = "/queryConditionConfig";
        break;
        // 首页
      case "systemIndex":
        func = "systemManage";
        page = "/systemIndex";
        break;
      case "tableEditService":
        func = "serviceConfigration";
        page = "/tableEditService";
        break;
      case "systemValidation": // 校验规则维护
        func = "systemManage";
        page = "/systemValidation";
        break;
      case "searchService": // 全文检索服务配置
        func = "serviceConfigration";
        page = "/fulltextSearchService";
        break;
      case "systemSetup": // 系统配置
        func = "systemManage";
        page = "/systemSetup";
        break;
      case "docSearchService": // 文档检索服务
        func = "serviceConfigration";
        page = "/docSearchService";
        break;
      case "systemDataConfigList": // 元数据配置列表
        func = "systemManage";
        page = "/systemDataConfigList";
        break;
      case "systemDataViewList":
        func = "systemManage";
        page = "/systemDataViewList";
        break;
        // 函数配置
      case "serviceFunc":
        func = "serviceConfigration";
        page = "/serviceFunc";
        break;
        // 多表跨库查询服务
      case "morejoinService":
        func = "serviceConfigration";
        page = "/moreJoinTableService";
        break;
      // 聚合服务
      case "polymService":
        func = "serviceConfigration";
        page = "/polymService";
        break;
        // 页面配置
      case "pageBaseInfo":
        func = "serviceConfigration";
        page = "/pageBaseInfo";
        break;
        // 页面配置详情
      case "pageDetailsInfo":
        func = "serviceConfigration";
        page = "/pageDetailsInfo";
        break;
        // 用户管理
      case "userManagement":
        func = "authorization";
        page = "/userManagement";
        break;

      case "callInterfaceRecordAnalyze":
        func = "dataAnalyze";
        page = "/CallInterfaceRecordAnalyze";
        break;
      case "systemDataContent":
        func = "project";
        page = "/systemDataContent";
        break;
      //调用放AppCode管理
      case "applicationCode":
        func = "accessControl";
        page = "/applicationCode";
        break;
      //调用方测站管理
      case "applicationGroupInfo":
        func = "accessControl";
        page = "/applicationGroupInfo";
        break;
      //
      case "applicationGroup":
        func = "accessControl";
        page = "/applicationGroup";
        break;
      // 测站管理
      case "acStationInfo":
        func = "accessControl";
        page = "/acStationInfo";
        break;
      // 测站管理新增
      case "acStationInfoSave":
        func = "accessControl";
        page = "/acStationInfoSave";
        break;
      // 访问控制，AppCode授权页面
      case "selectApplicationCode":
        func = "serviceConfigration";
        page = "/authconfig/selectApplicationCode";
        break;
      // 配置访问控制，AppCode授权精细化控制
      case "configApplicationCode":
        func = "serviceConfigration";
        page = "/authconfig/configApplicationCode";
        break;
      // 配置访问控制，AppCode授权精细化控制
      case "needWhitelist":
        func = "error";
        page = "/needWhitelist";
        break;
      default:
    }

    return func + page;
  }
  /**
   * 将文件转成base64 字符串
   *
   * @param path 文件路径
   * @return
   * @throws Exception
   */
  public static String encodeBase64File(String path) throws Exception {
    File file = new File(path);
    FileInputStream inputFile = new FileInputStream(file);
    byte[] buffer = new byte[(int) file.length()];
    inputFile.read(buffer);
    inputFile.close();
    return Base64.getEncoder().encodeToString(buffer);
  }
}
